package v1

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

type ApiBaseNoVerify struct {
	Base
}

func (b ApiBaseNoVerify) Json(code int, data interface{}, status string, message string, c *gin.Context) {

	if code == 0 {
		code = 200
	}

	c.JSON(http.StatusOK, gin.H{
		"code":   code,
		"data":   data,
		"status": status,
		"msg":    message,
	})
}

func (b ApiBaseNoVerify) Succee(data interface{}, c *gin.Context) {

	b.Json(200, data, "succee", "", c)
}

func (b ApiBaseNoVerify) Error(code int, data interface{}, msg string, c *gin.Context) {

	if code == 0 {
		code = -1
	}

	if msg == "" {
		msg = "数据错误"
	}
	b.Json(code, data, "error", msg, c)
}
